#!/usr/bin/perl

require './upgrade-lib.pl';

my ($err_msg, $out, $err_no, $log_ev, $log_msg, $log_lev, $sv_mount_dev);

#&ReadParse();

&ReadParseMime();

my $check_key=&check_key($in{'key'});
if($check_key == 0){
	open(UPLOAD, ">/sysvol/etc/trytime");
	print UPLOAD "F";
	close(UPLOAD);

	&header($text{'upgrade_succ'}, "", "index", 0, 1);
	print $check_key;
	&footer("index.cgi", "BACK");
}
elsif($check_key == 1){
	$err_msg = "Invalid Key:$in{'key'}";
	goto ERROR_OUT;
}
elsif($check_key == 2){
	$err_msg = "wrong format:$in{'key'}";
	goto ERROR_OUT;
}

$log_ev = $text{'naslog_ev_upgrade_succ'};
$log_msg = $text{'naslog_msg_upgrade_succ'};
&nas_syslog($text{'modulename'}, 'naslog_info', $log_ev, $log_msg);

#goto SUCC_OUT;
return;


ERROR_OUT:
&error_setup($text{'error_title'});
&error($err_msg);


SUCC_OUT:
$log_ev = $text{'naslog_ev_reboot'};
$log_msg = $text{'naslog_msg_mountdir'};
&nas_syslog($text{'modulename'}, 'naslog_info', $log_ev, $log_msg);
